package com.xzuf.core.ui;

import java.awt.BorderLayout;
import java.awt.Font;
import java.util.Iterator;
import java.util.List;

import javax.swing.JPanel;
import javax.swing.JScrollPane;

import org.jdesktop.swingx.JXTaskPane;
import org.jdesktop.swingx.JXTaskPaneContainer;

import com.xzuf.core.vo.PluginVO;

/**
 * @author xzgf
 * @since 2008-8-18
 * @version 1.0
 */
public class PluginTaskPane extends JPanel {

	public PluginTaskPane() {
		initPluginPane();
	}
	
	public void initPluginPane() {
		List<PluginVO> pluginList = ActionManager.refreshPluginTree();
		JXTaskPaneContainer container = new JXTaskPaneContainer();
		Font font = new Font("宋体", Font.BOLD, 12);
		JXTaskPane taskPane = new JXTaskPane();
		taskPane.setFont(font);
		taskPane.setTitle("控制台");
		JXTaskPane taskPane2 = new JXTaskPane();
		taskPane2.setFont(font);
		taskPane2.setTitle("功能节点");
		JXTaskPane taskPane3 = new JXTaskPane();
		taskPane3.setFont(font);
		taskPane3.setTitle("个人信息");
		if(pluginList != null && pluginList.size() > 0) {
			PluginVO vo = null;
			Iterator<PluginVO> iter = pluginList.iterator();
			while(iter.hasNext()) {
				vo = iter.next();
				String id = vo.getExtension().get(0).getExtensionid();
				PluginAction action = new PluginAction(vo);
				if(id.startsWith("1")) {
					taskPane.add(action);
				} else if(id.startsWith("2")) {
					taskPane2.add(action);
				} else if(id.startsWith("3")) {
					taskPane3.add(action);
				}
			}
		}
		container.add(taskPane);
		container.add(taskPane2);
		container.add(taskPane3);
		setLayout(new BorderLayout());
		add(new JScrollPane(container),BorderLayout.CENTER);
	}
}
